/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ocumed.teams.teamd.application;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import ocumed.teams.IBehandlung;
import ocumed.teams.IPosition;

/**
 *
 * @author Willi
 */
public class UntersuchungCellRenderer extends DefaultTableCellRenderer {
    private IBehandlung m_behandlung;
    
    public UntersuchungCellRenderer(IBehandlung b){
        m_behandlung = b;
    }
    
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        Component cell = super.getTableCellRendererComponent(table,
                value,
                isSelected,
                hasFocus,
                row, column);

        if (!isSelected) {
            UntersuchungTableModel mod = (UntersuchungTableModel) table.getModel();
            IPosition p = mod.getPosition(row);
            if (p.getiBehandlung() == m_behandlung) {
                cell.setBackground(new Color(255, 255, 255));
            } else {
                cell.setBackground(new Color(233, 233, 233));
            }
        }

        return cell;
    }
}
